package com.fgw.admin.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.fgw.admin.dto.ResultInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;

import com.fgw.admin.entity.ProjectSchedule;
import com.fgw.admin.service.IProjectScheduleService;

/**
 * 项目调度表 项目调度主表 前端控制器
 *
 * @author system
 * @date 2020-11-20 00:36:00
 */
@Controller
@RequestMapping("/projectSchedule")
public class ProjectScheduleController {
    @Resource
    private IProjectScheduleService iProjectScheduleService;

    @RequestMapping("/*")
    public void toHtml(){

    }

    @RequestMapping("/listData")
    @RequiresPermissions("projectSchedule:view")
    public @ResponseBody
    ResultInfo<List<ProjectSchedule>> listData(ProjectSchedule projectSchedule,@RequestParam(defaultValue="1") Integer page,@RequestParam(defaultValue="10") Integer limit){
        EntityWrapper<ProjectSchedule> wrapper = new EntityWrapper<>(projectSchedule);
        Page<ProjectSchedule> pageObj = iProjectScheduleService.selectPage(new Page<>(page,limit), wrapper);
        return new ResultInfo<>(pageObj.getRecords(), pageObj.getTotal());
    }

    @RequestMapping("/add")
    @RequiresPermissions("projectSchedule:add")
    public @ResponseBody
    ResultInfo<Boolean> add(ProjectSchedule projectSchedule){
        boolean b = iProjectScheduleService.insert(projectSchedule);
        return new ResultInfo<>(b);
    }

    @RequestMapping("/delBatch")
    @RequiresPermissions("projectSchedule:del")
    public @ResponseBody
    ResultInfo<Boolean> delBatch(Integer[] idArr){
        boolean b = iProjectScheduleService.deleteBatchIds(Arrays.asList(idArr));
        return new ResultInfo<>(b);
    }

    @RequestMapping("/edit")
    @RequiresPermissions("projectSchedule:edit")
    public @ResponseBody
    ResultInfo<Boolean> edit(ProjectSchedule projectSchedule){
        boolean b = iProjectScheduleService.updateById(projectSchedule);
        return new ResultInfo<>(b);
    }

}
